<?php
class Block_BlkSpecial extends Zend_View_Helper_Abstract{
    
    public function blkSpecial() {
        $view = $this->view;
        $arrParam = $view->arrParam;
        $flagShow = false;
        $currentPage = $arrParam['paginator']['currentPage'];
        if($arrParam['action'] == 'index' && $currentPage < 2){
            $flagShow = true;
        }
        if($flagShow){
            $db = Zend_Registry::get('connectDb');
    //        $db = Zend_Db::factory($adapter, $config);
            $select = $db->select()
                         ->from('products as p', array('id', 'name', 'picture', 'price', 'selloff', 'cat_id'))
                         ->join('product_category as pc', 'pc.id = p.cat_id', array('name as category_name'))
                         ->where('p.special = 1')
                         ->limit(4, 0)
                         ->order('RAND()');
            $rows = $db->fetchAll($select);
            require_once (BLOCK_PATH . '/BlkSpecial/default.php');
        }
    }
}